<template>
	<div>  
		<el-table :data="list" border fit highlight-current-row style="width: 100%" v-loading="listLoading" > 
			<slot />
		</el-table>
		<pagination v-show="page.total>0" :total="page.total" :page.sync="listQuery.pageNo" :limit.sync="listQuery.pageSize" @pagination="turnPage" />
	</div>
</template>

<script>
import Pagination from "@/components/Pagination";
export default {
	name: "simpleTable",
	components: { Pagination },
	props:{
		getList: {
        	type: Function,
        	default: null
      	},
      	listQuery: {
        	type: Object,
        	default: {}
      	},
     	pageSize: {
        	type: Number,
        	default: 10
      	},
      	loading: {
        	type: Boolean,
        	default: true
      	},
      	autoLoad: {
        	type: Boolean,
        	default: true
      	},
      	showPage: {
        	type: Boolean,
        	default: true
      	}
	},
	data() {
		return {
			listLoading:true,
			page: {
				pageNo: 1,
				pageSize: 10,
				total: 0
			},
      		list: [], // 数据集合
  		};
	},
	mounted(){
		this.listLoading = this.loading
		this.page.pageSize = this.pageSize || 10
		this.listQuery.pageNo=this.page.pageNo
		this.listQuery.pageSize=this.page.pageSize
		if(this.autoLoad){
			this.turnPage()
		}

	},
	methods: {
		load(list, total){
			this.list = list
			if(!this.showPage){
				this.page.total = 0
			} else {
				this.page.total = total	
			}
			
			this.listLoading=false
		},
		turnPage(a,b){
			this.$emit('getList', null)
		}
	}
};
</script>

<style scoped>
.pagination-container{
	margin:0;
}
>>> .el-table__body-wrapper{
  box-sizing: border-box;
  max-height:70vh!important;
  overflow-x: hidden;
  overflow-y: scroll;
  width: 100%;
}
</style>
